def insert_sort(alist):
    """插入排序"""

    # 列表的长度
    n = len(alist)
    # 控制轮数
    for i in range(1, n):
        for j in range(i, 0, -1):
            # 找到合适的位置安放我们的无序的数据
            if alist[j] < alist[j - 1]:
                alist[j], alist[j - 1] = alist[j - 1], alist[j]
            else:
                break


if __name__ == '__main__':
    alist = [1, 100, 99, 20, 5, 1000]
    insert_sort(alist)
    print(alist)
